package com.xudu.zerocodebackend.controller;

import com.xudu.zerocodebackend.common.BaseResponse;
import com.xudu.zerocodebackend.common.ResultUtils;
import com.xudu.zerocodebackend.model.entity.Car;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @className: Main
 * @description: TODO
 * @author: xudu
 * @create: 2025-07-27
 */
@RestController
@RequestMapping("/main")
public class MainController {

    @GetMapping("/hello")
    public BaseResponse<String> hello(String name) {
        return ResultUtils.success("hello " + " " + name);
    }

    @PostMapping(value = "/upload", consumes = "multipart/form-data")
    public String file(@RequestParam("file1") MultipartFile file1, @RequestParam("file2") MultipartFile file2) {
        return "hello world";
    }

    @PostMapping("get/car/info")
    public BaseResponse<Car> getCarInfo(@RequestBody Car car) {
        String name = car.getName();
        String brand = car.getBrand();
        double price = car.getPrice();
        String photo = car.getPhoto();
        System.out.println(name);
        System.out.println(brand);
        System.out.println(price);
        System.out.println(photo);

        return ResultUtils.success(car);
    }

}
